package com.adingxiong.cft;

import com.adingxiong.cft.config.ApplicationProperties;
import com.adingxiong.cft.config.FastdfsProperties;
import com.adingxiong.cft.config.MinioProperties;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@MapperScan(basePackages = "com.adingxiong.cft.mapper")
@ComponentScan("com.adingxiong.cft")
//自动加载配置类文件
@EnableConfigurationProperties({ApplicationProperties.class,FastdfsProperties.class,MinioProperties.class})
@Slf4j
public class CftApplication {

    public static void main(String[] args) throws UnknownHostException {

        SpringApplication app = new SpringApplication(CftApplication.class);

        Environment env = app.run(args).getEnvironment();
        String protocol = "http";

        log.info("\n----------------------------------------------------------\n\t" +
                        "Application '{}' is running! Access URLs:\n\t" +
                        "Local: \t\t{}://localhost:{}\n\t" +
                        "External: \t{}://{}:{}\n\t" +
                        "ApiDocs: \t{}\n" +
                        "ContextPath: \t{}\n----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                protocol,
                env.getProperty("server.port"),
                protocol,
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"),
                env.getProperty("application.doc"),
                env.getProperty("server.servlet.context-path"));
    }

}
